package com.baozheyangken.ai_learn.mapper;

import com.baozheyangken.ai_learn.pojo.entity.Permission;
import com.baozheyangken.ai_learn.pojo.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserMapper {
    void register(User user);

    Integer getIdByUsername(String username);

    Integer getIdByEmail(String email);

    void setRoleId(Integer userId, Integer roleId);

    User login(String username);

    User getUserById(Integer id);

    void updateUser(Integer id, String email, String password);
    
    void updateUser(Integer id, String username,String email, String password);


    List<Integer> getRoleIdByUserId(Integer id);

    void setUserStatus(Integer id);

    List<Permission> getUserPermission(List<Integer> roleIds);
    /**
     * 获取所有用户
     * @return 用户列表
     */
    List<User> getAllUsers();

    @Select("SELECT COUNT(*) > 0 FROM users WHERE id = #{id}")
    boolean existsById(Integer id);
}
